using Framework.UI;
using GameSystem;
using IcecreamView;
using UnityEngine;
using UnityEngine.UI;

namespace View
{
    public class ViewHomePanel : IC_AbstractModule
    {

        [BindUIPath("InputField")]
        private InputField _inputField;

        [BindUIButton("StartButton")]
        private void OnClick_StartGame()
        {
            GameManager.Instance.GameRoom.SetLevel(GameManager.Instance.GameRoom.NowLevel);
            GameManager.Instance.GameFsm.ChangeState(GameEnum.Loading, GameEnum.Game);
        }

        [BindUIButton("AboutButton")]
        private void OnClick_AboutGame() { UIManager.Instance.OpenView(UIPanel.AboutPanel, UILayer.Tip); }

        [BindUIButton("ExitButton")]
        private void OnClick_ExitGame() { Application.Quit(); }


        [BindUIButton("TestButton")]
        private void OnClick_TestGame()
        {
            if (string.IsNullOrWhiteSpace(this._inputField.text))
            {
                return;
            }
            GameManager.Instance.GameRoom.SetLevel(int.Parse(this._inputField.text));
            GameManager.Instance.GameFsm.ChangeState(GameEnum.Game);
        }

    }
}